package com.yckj.ytracker.api.util;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.regex.Pattern;

public final class IPUtil {

    private IPUtil() {
    }

    public static String getHostAddress() throws UnknownHostException {
        try {
            return (InetAddress.getLocalHost()).getHostAddress();
        } catch (UnknownHostException uhe) {
            String host = uhe.getMessage();
            if (host != null) {
                int colon = host.indexOf(':');
                if (colon > 0) {
                    return host.substring(0, colon);
                }
            }
            throw uhe;
        }
    }
}
